package game.classes;

import java.awt.Graphics;
import java.util.Vector;

/**
 * @author Chris
 */
public class Player {

    private String playername;
    private int points;
    private Ship ship;
    private boolean local;

    public Player(String name, boolean local) {
        this.playername = name;
        this.points = 0;
        this.local = local;

    }

    public Player(String name) {
        this.playername = name;
        this.points = 0;
        this.local = true;
    }

    public String getName() {
        return playername;
    }

    public void setName(String name) {
        playername = name;
    }

    public void addPoints(int points) {
        this.points += points;
    }

    public void resetPoints() {
        points = 0;
    }

    public int getPoints() {
        return points;
    }

    public void setShip(Ship ship) {
        this.ship = ship;
    }

    public Ship getShip() {
        return ship;
    }

    public void moveShip(int delta) {
        ship.move(delta);
    }

    public void drawShip(Graphics g) {
        ship.draw(g);
    }

    public void fire(Vector shots) {
        ship.fire(shots, local);
    }

    public int getShipEnergy() {
        return ship.getEnergy();
    }

    public void riseShipEnergy() {
        if (ship.getEnergy() < 25) {
            ship.setEnergy(ship.getEnergy() + 1);
        }
    }

    public boolean decShipEnergy() {
        ship.setEnergy(ship.getEnergy() - 1);
        if (ship.getEnergy() > 0) {
            ship.collided();
            return true;
        }
        return false;
    }
}
